package com.un.ebs.core.enums;

import lombok.Getter;

/**
 * @Description 达梦数据库数据类型
 * @Author lcl
 * @Date Created in 2021/1/26
 */
@Getter
public enum DmDataTypeEnum {
    NONE(DataTypeEnum.NONE, "未知", "text"),
    OBJECT(DataTypeEnum.OBJECT, "对象", "varchar"),
    STRING(DataTypeEnum.STRING, "字符", "varchar"),
    NUMBER(DataTypeEnum.NUMBER, "带小数的数值", "decimal"),
    INT(DataTypeEnum.INT, "整数值", "int"),
    DATE(DataTypeEnum.DATE, "日期", "date"),
    DATETIME(DataTypeEnum.DATETIME, "日期时间", "datetime"),
    MONEY(DataTypeEnum.MONEY, "金额", "decimal"),
    BOOLEAN(DataTypeEnum.BOOLEAN, "逻辑", "tinyint"),
    RESOURCE_DATA(DataTypeEnum.RESOURCE_DATA, "字典", "varchar");

    private final DataTypeEnum code;
    private final  String desc;
    private final  String value;

    DmDataTypeEnum(DataTypeEnum code, String desc, String value) {
        this.code = code;
        this.desc = desc;
        this.value = value;
    }

    public static DmDataTypeEnum getByCode(int code) {
        for (DmDataTypeEnum dmDataTypeEnum : values()) {
            if (dmDataTypeEnum.getCode().getCode() == code) {
                return dmDataTypeEnum;
            }
        }
        return null;
    }
}
